package io.yuncheng.modules.sys.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import io.yuncheng.common.utils.DateUtils;
import lombok.Data;

/**
 * 调用日志汇总
 *
 * @author jared
 * @email 15721509625@163.com
 * @date 2020-11-28 17:28:02
 */
@Data
@TableName("sub_app_log_collect")
public class SubAppLogCollectEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 *
	 */
	@TableId
	private Long id;
	/**
	 * 监管平台标识：省级 province_,地级市city_
	 */
	private Long appId;
	/**
	 * 时间
	 */
	private Date logDate;
	/**
	 * 算法时间map
	 */
	private String stepArithTime;
	/**
	 * 算法路径map
	 */
	private String stepArithPath;
	/**
	 * 创建时间
	 */
	private Date createDate;

	public Date buildByYear(){
		return  DateUtils.getYearFirstDate(this.getLogDate());
	}
	public Date buildByMonth(){
		return  DateUtils.getMonthFirstDate(this.getLogDate());
	}
	public String formatYearDate(){
		return DateUtils.formatYear(buildByYear());
	}
	public String formatMonthDate(){
		return DateUtils.formatMonth(buildByMonth());
	}

	/**
	 * 构建上传对象
	 * @param dept
	 * @param rootDeptId
	 * @return
	 */
	public SubAppLogCollectOuterEntity  buildByOuterEntity(Long dept,Long rootDeptId){
		SubAppLogCollectOuterEntity entity = new SubAppLogCollectOuterEntity();
		entity.setDeptId(dept);
		entity.setRootDeptId(rootDeptId);
		entity.setLogDate(getLogDate());
		entity.setStepArithPath(getStepArithPath());
		entity.setStepArithTime(getStepArithTime());
		return entity;
	}

}
